<template>
  <view class="address">
    <view v-if="false" class="address-box">
      <view class="address-box-text">
        <text>收 货 人: {{aree.name}}</text>
        <text>电话: {{aree.phone}} <uni-icons type="right" size="18"></uni-icons></text>
      </view>
      <text>收获地址: {{aree.dz}}</text>
    </view>
    <view v-else class="address-but">
      <button @click="addAddress">请添加收获地址+</button>
    </view>
    <view class="pic">
      <image src="../../static/cart_border@2x.png" mode="aspectFill"></image>
    </view>
  </view>
</template>

<script>

  export default {
    name:"my-address",
    props: {
      aree: Object
    },
    data() {
      return {
        // address: userStore.address,

      };
    },

    methods: {
      async addAddress() {
         // uni.navigateTo({
         //   url: '/subpkg/address/address'
         // })
         await uni.chooseAddress({  
           success: function (res) {  
             console.log('选择的地址：', res.addrInfo);  
             // res.addrInfo 包含用户选择的地址信息  
             // {  
             //   "name": "张三",  
             //   "telNumber": "13800138000",  
             //   "provinceName": "广东省",  
             //   "cityName": "广州市",  
             //   "countyName": "海珠区",  
             //   "detailInfo": "新港中路397号",  
             //   "nationalCode": "86",  
             //   "postalCode": "510000"  
             // }  
           },  
           fail: function (err) {  
             console.error('选择地址失败：', err);  
           }  
         });
      },
      
    },
    
  }
</script>

<style lang="scss">
  .address {
     position: relative;
     display: flex;
     justify-content: center;
     align-items: center;
     height: 80px;
  }
  .address-box {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  
  font-size: 12px;
  padding: 20px 5px; 
  text {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }
  .address-box-text {
    display: flex;
    justify-content: space-between;
  }
}
  .pic{
    position: absolute;
    bottom: 0;
    image {
      display: block;
      width: 100vw;
      height: 5px;
    }
  }
  .address-but {
    display: inline-block;
    margin: auto auto;
    button {
      padding: 0 15px;
      font-size: 12px;
      background-color: #1cab1b;
      color: #fff;
      border-radius: 5px;
    }
  }
</style>